package response

import (
	"time"
	"tuowei.com/app/admin/models"
)

type Course struct {
	CourseId     int    `json:"course_id"`              // 课程id
	Cover        string `json:"cover"`                  //课程封面
	Name         string `json:"name"`                   //课程名
	Introduction string `json:"introduction,omitempty"` //课程简介

}
type GetOrderListResponse struct {
	Id          int      `json:"id"`
	Name        string   `json:"name"`
	Phone       string   `json:"phone"`
	Courses     []Course `json:"courses"`
	CompletePay int      `json:"complete_pay"`
}
type CourseNames []string

type orderDetailResponse struct {
	Id                  int         `json:"id"`
	Name                string      `json:"name"`
	Phone               string      `json:"phone"`
	CollegeName         string      `json:"college_name"` //就读院校
	Subject             string      `json:"subject"`      // 科目
	CourseNames         CourseNames `json:"course_names"` //购买的课程名字
	OrderNumber         string      `json:"order_number"` //订单编号
	Price               float64     `json:"price"`
	ActualIncome        float64     `json:"actual_income"`    //实际收款
	ReceiptNumber       string      `json:"receipt_number"`   //收据编号
	AgreementNumber     string      `json:"agreement_number"` //协议编号
	Recheck             string      `json:"recheck"`          //复审意见
	UpdatedAt           time.Time   `json:"updated_at"`       //更新时间==复审时间
	CreatedAt           time.Time   `json:"created_at"`
	CompletePay         int         `json:"complete_pay"`
	KeBie               string      `json:"ke_bie"` // 科别
	Records             []*models.OfflineOrderProgress
	Status              int    `json:"status"`
	EnrollmentTeacherId int    `json:"enrollment_teacher_id"`
	ContractUrl         string `json:"contract_url"`    // 电子合同路径
	ContractNumber      string `json:"contract_number"` //电子合同路径
	TemplateId          string `json:"template_id"`     // e签模版id
	FileName            string `json:"file_name"`       //文件模板名字
}

type GetOrderDetailResponse struct {
	Detail          orderDetailResponse
	FollowDirection interface{}
}

func (o *GetOrderDetailResponse) Make(model models.OfflineOrder) {
	o.Detail.Id = model.Id
	o.Detail.Name = model.Customer.Name
	o.Detail.Phone = model.Customer.Phone
	o.Detail.CollegeName = model.Customer.College.CollegesName
	if model.SubjectRelation != nil {
		o.Detail.Subject = model.SubjectRelation.Name
	}
	for _, v := range model.Course {
		o.Detail.CourseNames = append(o.Detail.CourseNames, v.Name)
		o.Detail.TemplateId = v.FileId
	}
	o.Detail.OrderNumber = model.OrderNumber
	o.Detail.Price = model.Price
	o.Detail.CreatedAt = model.CreatedAt
	o.Detail.CompletePay = model.CompletePay
	o.Detail.Status = model.Status
	if model.Customer != nil {
		o.Detail.EnrollmentTeacherId = model.Customer.EnrollmentTeacherId
		o.Detail.KeBie = model.Customer.KeBie
	}
	o.Detail.Records = model.Records
	o.FollowDirection = models.FollowDirectionMap
	o.Detail.ActualIncome = model.ActualIncome
	o.Detail.ContractUrl = model.ContractUrl
	o.Detail.ContractNumber = model.ContractNumber
}
